<?php
defined('BASEPATH') OR exit('No direct script access allowed');

/**
* 文章管理模型
*/
class Sent_model extends CI_Model{
	
	//发表文章
	public function article_add($data){
		$this->db->insert('article',$data);
		
	}
	//查看文章
	public function article_find(){
	$data = $this->db->select('aid,title,cname,time')->from('article')->join('editor','article.cid = editor.cid')->order_by('aid','arc')->get()->result_array();
//join第一个参数关联的表，与哪张表来关联

		return $data;
	}
	
	//调用前台文章
	public function article_check(){
		$this->db->limit(5);
		//普通文章
$data['ord'] = $this->db->select('aid,thumb,title,info')->order_by('time','desc')->
get_where('article',array('type'=>0))->result_array();

//$data['art'] = $this->db->select('aid,thumb,title,info')->order_by('time', 'desc')->get_where('article', array('type'=>0))->result_array();
$this->db->limit(5);
        //	热门文章
	$data['hat'] = $this->db->select('aid,thumb,title,info')->order_by('time','desc')->
get_where('article',array('type'=>1))->result_array();

	return $data;
	
	//注1为热门招聘，0为普通招聘
	}
	
	//右侧标题
	public function article_right(){
		$this->db->limit(5);
		$data = $this->db->select('aid,title')->order_by('time','desc')->get('article')->result_array();
//		$data = $this->db->get()
		return $data;
	}
	
	//标签页
	public function artice_col($cid){
		$data = $this->db->select('aid,title,thumb,info,time')->order_by('time','desc')->get_where('article',array('cid' =>$cid))->result_array();
		return $data;
	}
	
	//文章页
	public function article_art($aid){
		$data = $this->db->join('editor','article.cid = editor.cid')->get_where('article',array('aid'=>$aid))->result_array();
		return $data;
	}
	
	//搜索功能
	public function solo($input){
		$this->db->select('aid,title,info,content,thumb,time');
		$this->db->where(array('title'=>$input));
		$data = $this->db->get('article')->result_array();
		return $data;
	}

}